<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数值更新系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }
        
        .container {
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 20px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            padding: 40px;
            width: 100%;
            max-width: 600px;
            text-align: center;
        }
        
        h1 {
            color: #333;
            margin-bottom: 30px;
            font-size: 2.5rem;
        }
        
        .value-display {
            background: linear-gradient(45deg, #ff9966, #ff5e62);
            color: white;
            font-size: 5rem;
            font-weight: bold;
            padding: 30px;
            border-radius: 15px;
            margin: 30px 0;
            box-shadow: 0 5px 15px rgba(255, 94, 98, 0.4);
            transition: all 0.3s ease;
        }
        
        .value-display.changed {
            transform: scale(1.05);
            box-shadow: 0 8px 20px rgba(255, 94, 98, 0.6);
        }
        
        .controls {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 15px;
            margin-bottom: 30px;
        }
        
        button {
            background-color: #4a6ee0;
            color: white;
            border: none;
            padding: 15px 25px;
            font-size: 1.1rem;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease;
            flex: 1;
            min-width: 140px;
            box-shadow: 0 4px 8px rgba(74, 110, 224, 0.3);
        }
        
        button:hover {
            background-color: #3a5ecf;
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(74, 110, 224, 0.4);
        }
        
        button:active {
            transform: translateY(1px);
        }
        
        .increment {
            background-color: #2ecc71;
            box-shadow: 0 4px 8px rgba(46, 204, 113, 0.3);
        }
        
        .increment:hover {
            background-color: #27ae60;
            box-shadow: 0 6px 12px rgba(46, 204, 113, 0.4);
        }
        
        .decrement {
            background-color: #e74c3c;
            box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
        }
        
        .decrement:hover {
            background-color: #c0392b;
            box-shadow: 0 6px 12px rgba(231, 76, 60, 0.4);
        }
        
        .reset {
            background-color: #f39c12;
            box-shadow: 0 4px 8px rgba(243, 156, 18, 0.3);
        }
        
        .reset:hover {
            background-color: #d35400;
            box-shadow: 0 6px 12px rgba(243, 156, 18, 0.4);
        }
        
        .custom-control {
            display: flex;
            gap: 10px;
            margin-top: 20px;
        }
        
        input {
            flex: 1;
            padding: 15px;
            border: 2px solid #ddd;
            border-radius: 10px;
            font-size: 1.1rem;
            text-align: center;
        }
        
        input:focus {
            border-color: #4a6ee0;
            outline: none;
        }
        
        .history {
            margin-top: 30px;
            text-align: left;
        }
        
        .history h3 {
            color: #333;
            margin-bottom: 15px;
            text-align: center;
        }
        
        .history-list {
            max-height: 150px;
            overflow-y: auto;
            background-color: #f8f9fa;
            border-radius: 10px;
            padding: 15px;
        }
        
        .history-item {
            padding: 8px 0;
            border-bottom: 1px solid #eee;
            color: #555;
        }
        
        .history-item:last-child {
            border-bottom: none;
        }
        
        @media (max-width: 600px) {
            .container {
                padding: 25px;
            }
            
            h1 {
                font-size: 2rem;
            }
            
            .value-display {
                font-size: 4rem;
                padding: 20px;
            }
            
            button {
                padding: 12px 20px;
                font-size: 1rem;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>数值更新系统</h1>
        
        <div class="value-display" id="valueDisplay">0</div>
        
        <div class="controls">
            <button class="increment" onclick="changeValue(1)">+1</button>
            <button class="decrement" onclick="changeValue(-1)">-1</button>
            <button class="reset" onclick="resetValue()">重置</button>
        </div>
        
        <div class="custom-control">
            <input type="number" id="customValue" placeholder="输入自定义数值">
            <button onclick="setCustomValue()">设置</button>
        </div>
        
        <div class="history">
            <h3>操作历史</h3>
            <div class="history-list" id="historyList">
                <!-- 历史记录将在这里显示 -->
            </div>
        </div>
    </div>

    <script>
        // 初始数值
        let currentValue = 0;
        let history = [];
        
        // 更新显示的函数
        function updateDisplay() {
            const display = document.getElementById('valueDisplay');
            display.textContent = currentValue;
            
            // 添加动画效果
            display.classList.add('changed');
            setTimeout(() => {
                display.classList.remove('changed');
            }, 300);
        }
        
        // 改变数值的函数
        function changeValue(amount) {
            const oldValue = currentValue;
            currentValue += amount;
            updateDisplay();
            
            // 记录历史
            const operation = amount > 0 ? `增加 ${amount}` : `减少 ${Math.abs(amount)}`;
            addHistory(oldValue, currentValue, operation);
        }
        
        // 重置数值
        function resetValue() {
            const oldValue = currentValue;
            currentValue = 0;
            updateDisplay();
            
            // 记录历史
            addHistory(oldValue, currentValue, "重置");
        }
        
        // 设置自定义数值
        function setCustomValue() {
            const input = document.getElementById('customValue');
            const newValue = parseInt(input.value);
            
            if (!isNaN(newValue)) {
                const oldValue = currentValue;
                currentValue = newValue;
                updateDisplay();
                
                // 记录历史
                addHistory(oldValue, currentValue, `设置为 ${newValue}`);
                
                // 清空输入框
                input.value = '';
            } else {
                alert('请输入有效的数字！');
            }
        }
        
        // 添加历史记录
        function addHistory(oldValue, newValue, operation) {
            const now = new Date();
            const timeString = now.toLocaleTimeString();
            
            history.unshift({
                time: timeString,
                operation: operation,
                oldValue: oldValue,
                newValue: newValue
            });
            
            // 限制历史记录数量
            if (history.length > 10) {
                history.pop();
            }
            
            updateHistoryDisplay();
        }
        
        // 更新历史记录显示
        function updateHistoryDisplay() {
            const historyList = document.getElementById('historyList');
            historyList.innerHTML = '';
            
            history.forEach(item => {
                const historyItem = document.createElement('div');
                historyItem.className = 'history-item';
                historyItem.textContent = `${item.time}: ${item.operation} (${item.oldValue} → ${item.newValue})`;
                historyList.appendChild(historyItem);
            });
        }
        
        // 初始化显示
        updateDisplay();
        updateHistoryDisplay();
        
        // 添加键盘快捷键支持
        document.addEventListener('keydown', function(event) {
            if (event.key === 'ArrowUp') {
                changeValue(1);
            } else if (event.key === 'ArrowDown') {
                changeValue(-1);
            } else if (event.key === 'r' || event.key === 'R') {
                resetValue();
            }
        });
    </script>
</body>
</html>